<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>IfInString / IfNotInString</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>IfInString / IfNotInString</h1>

<p>Checks if a <a href="../Variables.htm">variable</a> contains the specified string.</p>

<pre class="Syntax">IfInString, var, SearchString
IfNotInString, var, SearchString
Position := <a href="../Functions.htm#InStr">InStr</a>(Haystack, Needle [, CaseSensitive?, StartingPos]]) <em>; See the <a href="../Functions.htm#InStr">InStr() function</a> for details.</em></pre>
<h3>Parameters</h3>
<dl>

  <dt>var</dt>
  <dd><p>The name of the <a href="../Variables.htm">variable</a> whose contents will be searched for a match.</p></dd>

  <dt>SearchString</dt>
  <dd><p>The string to search for. Matching is not case sensitive unless <a href="StringCaseSense.htm">StringCaseSense</a> has been turned on.</p></dd>

</dl>

<h3>Remarks</h3>
<p>The built-in variables <a href="../Variables.htm">%A_Space%</a> and <a href="../Variables.htm">%A_Tab%</a> contain a single space and a single tab character, respectively, which might be useful when searching for these characters alone.</p>
<p>Another command can  appear on the same line as this one. In other words, both of these are equivalent:</p>
<pre>IfInString, MyVar, abc, Gosub, Process1
IfInString, MyVar, abc
    Gosub, Process1</pre>
<p>However, items other than named commands are not supported on the same line. For example:</p>
<pre>IfInString, MyVar, abc, found := true  <em><strong>; Invalid.</strong></em></pre>
<h3>Related</h3>
<p><a href="../Functions.htm#InStr">InStr()</a>, <a href="RegExMatch.htm">RegExMatch()</a>, <a href="StringGetPos.htm">StringGetPos</a>, <a href="StringCaseSense.htm">StringCaseSense</a>, <a href="IfEqual.htm">IfEqual</a>, <a href="IfIn.htm">if var in/contains MatchList</a>, <a href="IfBetween.htm">if var between</a>, <a href="IfIs.htm">if var is type</a>, <a href="Block.htm">Blocks</a>, <a href="Else.htm">Else</a></p>
<h3>Example</h3>
<pre class="NoIndent">Haystack = abcdefghijklmnopqrs
Needle = abc
IfInString, Haystack, %Needle%
{
    MsgBox, The string was found.
    return
}
else
    Sleep, 1</pre>

</body>
</html>
